from matplotlib.ticker import MultipleLocator, FormatStrFormatter
from astro.cosmology import Cosmology,PC

z = np.linspace(0,5,1e3)

for hval in (70,73,76):
    c = Cosmology(HO=hval)
    const = 1. / PC / 1.e6 * (1./60 * np.pi / 180.)
    #davals = [c.Da(i)*const for i in z]
    dmvals = [c.Dm(i)*const for i in z]
    plot(z,dmvals,'b',lw=2)
    plot(z,dmvals/(1+z),'r',lw=1)

pl.legend(['Comoving','Proper'],loc='upper left')
xminorlocator = MultipleLocator(0.1)
yminorlocator = MultipleLocator(0.1)
pl.xlabel('Redshift')
pl.ylabel('Transverse distance (Mpc) per arcmin')
#pl.grid(which='minor')
pl.grid()
pl.gca().xaxis.set_minor_locator(xminorlocator)
pl.gca().yaxis.set_minor_locator(yminorlocator)
pl.title('for H$_0$ = 70 (top) ,73 (middle),76 (bottom)',fontsize=14)

# plot of distance per unit redshift distance as a function of redshift
fig = pl.figure()
a = fig.add_subplot(111)
dz = 0.01
Mpc_per_dz = [(c.Dm(zval+dz) - c.Dm(zval)) / PC / 1.e6  for zval in z]
pl.ylabel('Mpc per dz=0.01 interval')
pl.xlabel('Redshift')

#pl.savefig('trans_dist.png')
pl.show()
